<?php

?>
<script type="text/javascript">
var tinyMCEIMGCOnfig = { 
	path:<?php echo ( !empty( $SitePath )?"'$SitePath'":"" ); ?>,
	maxWidth:<?php echo ( !empty( $maxWidth )?"'$maxWidth'":800 );?>,
	popupWidth:<?php echo ( !empty( $popupWidth )?"'$popupWidth'":600 );?>,
	popupHeight:<?php echo ( !empty( $popupHeight )?"'$popupHeight'":500 );?>
};
var imgDat = [ 
<?php 
  $ctr =0;
  if( is_array($categories) ){
	foreach ($categories as $category ){
		echo "{";
		echo "id:$category->id,";
		echo "name:'$category->name',";
		echo "images:";
		$ctr2 = 0;
		if(is_array($category->imgs)){
			echo "[";
			foreach ( $category->imgs as $img ){
				echo "{";
				echo "id:$img->id,";
				echo "width:$img->width,";
				echo "height:$img->height,";
				echo "short_desc:'$img->short_desc',";
				echo "title:'$img->title'";
				echo "}";
				echo ( $ctr2 < count( $category->imgs )-1 )?",":"";
				$ctr2 ++;
			}
			echo "]";
		}
		else echo "[]";
		echo "}";
		echo ($ctr < count($categories)-1 )?",":"";
		$ctr ++;
	}
  }
              ?>
   ];
tinyMCE.init({
    mode : "textareas",
    convert_urls : false,
    theme : "advanced",
    plugins : "emotions,spellchecker,advhr,insertdatetime,preview,GWImage,table", 
            
    // Theme options - button# indicated the row# only
    theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect,table",
    theme_advanced_buttons2 : "cut,copy,paste,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,GWImage,|,code,preview,|,forecolor,backcolor,insertdate,inserttime,|,spellchecker,advhr,,removeformat,|,sub,sup,|,charmap,emotions",
    theme_advanced_buttons3 : "",      
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true
});
</script>
<?php  
	$hidden = array(
		'refurl' => $refurl,
		'content_editor_type' => $section_type,
		'content_id' => $content_id
	);
	$attr = array(
	 'id' => 'tiny_mce'
	);
	echo form_open("$action/$id/",$attr,$hidden);
	$insert = 'To begin, write some text here for your article...';
	if(!empty($content)){
		$insert = $content;
	}
?>
        <div class="tiny">     
                <textarea name="content" cols="<?php echo $numCols; ?>" rows="<?php echo $numRows; ?>"><?php echo $insert; ?></textarea>
        </div>
       <div class="form_controls" >
       <input type="submit" value="Cancel" id="cancel" name="cancel" class="niceform" />
       <input type="submit" value="Save" id="update" name="update" class="niceform" />
       </div>   
</form>